class EventBlob < ActiveRecord::Base
  belongs_to :event
  belongs_to :assignment, :class_name => 'Assignment', :foreign_key => 'event_id'

  validates_presence_of :data, :message => 'Debes contestar con alg&uacute;n dato.'

  def data=(param)
    if param.is_a?(StringIO) or param.is_a?(Tempfile)
      self[:file_name] = just_filename = param.original_filename.gsub(/^.*(\\|\/)/, '')
      self[:data] = param.read
    else
      self[:data] = param
    end
  end

end
